package com.kokos.dao;

import javax.persistence.EntityManager;

public abstract class AbstractDAOFacade<T> implements AbstractDAOFacadeLocal<T> {

	private Class<T> entityClass;

	public AbstractDAOFacade(Class<T> entityClass) {
		this.entityClass = entityClass;
	}

	protected abstract EntityManager getEntityManager();

	public void save(T entity) {
		getEntityManager().persist(entity);
	}
	
	public void modify(T entity) {
		getEntityManager().merge(entity);
	}

	public void drop(T entity) {
		getEntityManager().remove(getEntityManager().merge(entity));
	}

	public T find(Object id) {
		return getEntityManager().find(entityClass, id);
	}
	
}
